import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: const Text('你好Flutter')),
      //body内定义多个组件
      body: const Column(
        children: [
          MyApp(),
          MyButton()
        ],
      )

    ),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
        child: Container(
      alignment: Alignment.center,
      //配置container中元素方位
      width: 200,
      height: 200,
      // transform: Matrix4.translationValues(10, 0, 0), //位移
      // transform: Matrix4.rotationZ(0.2), //旋转
      transform: Matrix4.skewY(0.2), //旋转
      decoration: BoxDecoration(
          color: Colors.yellow,
          //背景颜色
          border: Border.all(
            //边框
            color: Colors.red,
            width: 2,
          ),
          borderRadius: BorderRadius.circular(10),
          //配置圆角
          boxShadow: const [
            //配置阴影效果
            BoxShadow(color: Colors.black, blurRadius: 10.0)
          ],
          //配置渐变效果 红色渐变到黄色
          gradient: const LinearGradient(colors: [Colors.red, Colors.yellow])),
      child: const Text(
        "你好Flutter",
        style: TextStyle(color: Colors.black, fontSize: 20),
      ),
    ));
  }
}

class MyButton extends StatelessWidget {
  const MyButton({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      width: 200,
      height: 40,
      //设置margin
      margin: const EdgeInsets.fromLTRB(0, 20, 0, 0),
      decoration: BoxDecoration(
        color: Colors.blue,
        borderRadius: BorderRadius.circular(10),
      ),
      child: const Text(
        "按钮",
        style: TextStyle(
          color: Colors.white,
          fontSize: 20,
        ),
      ),
    );
  }
}
